package com.molin.StreamTest;

import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;

public class Lianxi01 {
    public static void main(String[] args) {
        Map<String, Integer> manAc = new TreeMap<>();
        manAc.put("张国立", 0);
        manAc.put("张晋", 0);
        manAc.put("刘烨", 0);
        manAc.put("郑伊健", 0);
        manAc.put("徐峥", 0);
        manAc.put("王宝强", 0);

        Map<String, Integer> womanAc = new TreeMap<>();
        womanAc.put("郑爽", 1);
        womanAc.put("杨幂", 1);
        womanAc.put("关晓彤", 1);
        womanAc.put("张天爱", 1);
        womanAc.put("杨紫", 1);
        womanAc.put("赵丽颖", 1);


        Stream<String> stream01 = manAc.keySet().stream().filter(name -> name.length() == 3).limit(2);
        Stream<String> stream02 = womanAc.keySet().stream().filter(name -> name.startsWith("杨")).skip(1);
        Stream<String> stream03 = Stream.concat(stream01, stream02);
        List<String> newActors=stream03.collect(Collectors.toList());
        System.out.println(newActors);

        Set<Actor> actorSet=new TreeSet<Actor>((Actor o1,Actor o2)->{return o1.getName().compareTo(o2.getName());});

        Iterator iterator=newActors.iterator();
        while (iterator.hasNext()){
            String actorName=iterator.next().toString();
            if(manAc.containsKey(actorName)){
                //男性
                actorSet.add(new Actor(actorName,0));
            }else {
                actorSet.add(new Actor(actorName,1));
            }
        }
        System.out.println(actorSet);
    }
}
class Actor {
    private String name;
    private int sex;

    @Override
    public String toString() {
        return "Actor{" +
                "name='" + name + '\'' +
                ", sex=" + sex +
                '}';
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getSex() {
        return sex;
    }

    public void setSex(int sex) {
        this.sex = sex;
    }

    public Actor() {
    }

    public Actor(String name, int sex) {
        this.name = name;
        this.sex = sex;
    }
}